import {Result} from '@/base/Result';
import {request} from '@/base/Request';
import {Page} from '@/base/Page';
import {DeviceMaintainRule} from '@/base/model/DeviceMaintainRule';
import qs from 'qs'
import {Sug} from '@/base/model/Sug';

export function getDeviceMaintainList(params: {
  pageIndex: number;
  pageSize: number;
  sortDirection: string;
  sortId?:number;
  modelName?:string;
}): Promise<Result<Page<DeviceMaintainRule>>> {
  return request.getPage(DeviceMaintainRule, '/api/device-model', {params});
}

export function putDeviceMaintain(params: {
  id: number,
  usageTime: number,
  // description:string
}) {
  return request.put(DeviceMaintainRule, '/api/device-model/updateLifeTime', qs.stringify(params));
}

export function getSugList(params: {
  pageIndex: number;
  pageSize: number;
  sortDirection: string;
  type:number;
  name?:string;
  tel?:string;
  createBegin?: string,
  createEnd?: string,
  cityId?: number,
  provinceId?: number,
  searchAgentId?: number
}): Promise<Result<Page<Sug>>> {
  return request.getPage(Sug, '/api/post-sale/fetchMaintainList', {params});
}
export function getSug(params:{
  id: number;
  aid: number
}): Promise<Result<String>> {
  return request.get(String, '/api/post-sale/sugDetail',{params});
}
export function delSug(id: number): Promise<Result<void>> {
  return request.delete(`/api/post-sale/sugDetail/${id}`);
}
